/*
 * EmploymentDetails.java
 *
 * Created on 31 March 2009, 12:39
 */

package uk.co.exahertz.friendlysociety.gui;
import java.awt.Toolkit;
import javax.swing.JOptionPane;
import uk.co.exahertz.friendlysociety.core.*;
import java.util.GregorianCalendar;

/**
 *
 * @author  kal8
 */
public class EmploymentDetails extends javax.swing.JFrame {
    private Core core;
    private Customer customer;
    private Employment employment;

    /** Creates new form EmploymentDetails */
    public EmploymentDetails(final Core core, final Customer customer,
            final Employment employment) {
        if(core == null) throw new IllegalArgumentException("The core " +
                "instance must not be null.");
        if(customer == null) throw new IllegalArgumentException("The " +
                "customer instance must not be null.");
        if(employment == null) throw new IllegalArgumentException("The " +
                "employment instance must not be null.");
        this.core = core;
        this.customer = customer;
        this.employment = employment;
        initComponents();
        jLabelID.setText(customer.getFullName());
        setResizable(false);
        setLocation(200, 210);
        this.core = core;
        this.customer = customer;
        setIconImage(Toolkit.getDefaultToolkit().getImage(
        CustomerOption.class.getResource("images/friendlyicon.jpg")));
        
        jLabelID.setText(customer.getFullName());
        jTextFieldEmployerName.setText(employment.getEmployerName());
        jTextFieldPhone.setText(employment.getEmployerTelephone());
        jTextFieldFax.setText(employment.getEmployerFax());
        jTextFieldStarted.setText(employment.getDateStarted().get(
                GregorianCalendar.DAY_OF_MONTH) + "/" +
                employment.getDateStarted().get(GregorianCalendar.MONTH) + "/" +
                employment.getDateStarted().get(GregorianCalendar.YEAR));
        if(employment.getDateEnded() != null) {
            jTextFieldEnded.setText(employment.getDateEnded().get(
                    GregorianCalendar.DAY_OF_MONTH) + "/" +
                    employment.getDateEnded().get(GregorianCalendar.MONTH) +
                    "/" + employment.getDateEnded().get(GregorianCalendar.YEAR));
        }
        jTextFieldHours.setText(Float.toString(employment.getHoursPerWeek()));
        jTextFieldSalary.setText(Float.toString(
                employment.getCurrentAnnualSalery()));
        jCheckBoxPermenant.setSelected(employment.isEmploymentPermenant());
        jCheckBoxSelfEmployed.setSelected(employment.isSelfEmployed());
        jTextFieldName.setText(
                employment.getEmployerAddressObject().getPropertyName());
        jTextFieldStreet.setText(
                employment.getEmployerAddressObject().getStreetName());
        jTextFieldTown.setText(employment.getEmployerAddressObject().getTown());
        jTextFieldCountry.setText(
                employment.getEmployerAddressObject().getCountry());
        jTextFieldPostCode.setText(
                employment.getEmployerAddressObject().getPostCode());
        core.addForm(this);
    }
    
    @Override
    public void dispose() {
        core.removeForm(this);
        super.dispose();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabelIcon = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jPanel3 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabelName = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabelID = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTextFieldEmployerName = new javax.swing.JTextField();
        jTextFieldPhone = new javax.swing.JTextField();
        jTextFieldFax = new javax.swing.JTextField();
        jTextFieldStarted = new javax.swing.JTextField();
        jTextFieldEnded = new javax.swing.JTextField();
        jTextFieldHours = new javax.swing.JTextField();
        jTextFieldSalary = new javax.swing.JTextField();
        jCheckBoxSelfEmployed = new javax.swing.JCheckBox();
        jCheckBoxPermenant = new javax.swing.JCheckBox();
        jPanel4 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jTextFieldName = new javax.swing.JTextField();
        jTextFieldStreet = new javax.swing.JTextField();
        jTextFieldTown = new javax.swing.JTextField();
        jTextFieldCountry = new javax.swing.JTextField();
        jTextFieldPostCode = new javax.swing.JTextField();
        jButtonSubmit = new javax.swing.JButton();
        jButtonBack = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("uk/co/exahertz/friendlysociety/gui/Bundle"); // NOI18N
        setTitle(bundle.getString("EmploymentDetails.title")); // NOI18N

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel1.setText(bundle.getString("EmploymentDetails.jLabel1.text")); // NOI18N

        jLabelIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/co/exahertz/friendlysociety/gui/images/friendlysocietywatermarkmini.jpg"))); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(156, 156, 156)
                        .addComponent(jLabel1))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 586, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelIcon)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(47, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(43, Short.MAX_VALUE)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(39, 39, 39))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jLabelIcon)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel11.setText(bundle.getString("EmploymentDetails.jLabel11.text")); // NOI18N

        jLabel2.setText(bundle.getString("EmploymentDetails.jLabel2.text")); // NOI18N

        jLabelName.setText(bundle.getString("EmploymentDetails.jLabelName.text")); // NOI18N

        jLabel3.setText(bundle.getString("EmploymentDetails.jLabel3.text")); // NOI18N

        jLabel4.setText(bundle.getString("EmploymentDetails.jLabel4.text")); // NOI18N

        jLabel5.setText(bundle.getString("EmploymentDetails.jLabel5.text")); // NOI18N

        jLabel6.setText(bundle.getString("EmploymentDetails.jLabel6.text")); // NOI18N

        jLabel7.setText(bundle.getString("EmploymentDetails.jLabel7.text")); // NOI18N

        jLabelID.setText(bundle.getString("EmploymentDetails.jLabelID.text")); // NOI18N

        jLabel8.setText(bundle.getString("EmploymentDetails.jLabel8.text")); // NOI18N

        jTextFieldEmployerName.setText(bundle.getString("EmploymentDetails.jTextFieldEmployerName.text")); // NOI18N

        jTextFieldPhone.setText(bundle.getString("EmploymentDetails.jTextFieldPhone.text")); // NOI18N

        jTextFieldFax.setText(bundle.getString("EmploymentDetails.jTextFieldFax.text")); // NOI18N

        jTextFieldStarted.setText(bundle.getString("EmploymentDetails.jTextFieldStarted.text")); // NOI18N

        jTextFieldEnded.setText(bundle.getString("EmploymentDetails.jTextFieldEnded.text")); // NOI18N

        jTextFieldHours.setText(bundle.getString("EmploymentDetails.jTextFieldHours.text")); // NOI18N

        jTextFieldSalary.setText(bundle.getString("EmploymentDetails.jTextFieldSalary.text")); // NOI18N

        jCheckBoxSelfEmployed.setBackground(new java.awt.Color(255, 255, 255));
        jCheckBoxSelfEmployed.setText(bundle.getString("EmploymentDetails.jCheckBoxSelfEmployed.text")); // NOI18N

        jCheckBoxPermenant.setBackground(new java.awt.Color(255, 255, 255));
        jCheckBoxPermenant.setText(bundle.getString("EmploymentDetails.jCheckBoxPermenant.text")); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jCheckBoxPermenant)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jCheckBoxSelfEmployed))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabelName)
                                .addComponent(jLabel3)
                                .addComponent(jLabel4)
                                .addComponent(jLabel5)
                                .addComponent(jLabel6)
                                .addComponent(jLabel7)
                                .addComponent(jLabel8)))
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(4, 4, 4)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jTextFieldEnded)
                                    .addComponent(jTextFieldStarted)
                                    .addComponent(jTextFieldFax)
                                    .addComponent(jTextFieldPhone)
                                    .addComponent(jTextFieldHours)
                                    .addComponent(jTextFieldSalary)
                                    .addComponent(jTextFieldEmployerName, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabelID, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.LEADING))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jLabel11)
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabelID, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelName)
                    .addComponent(jTextFieldEmployerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextFieldFax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTextFieldStarted, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jTextFieldEnded, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jTextFieldHours, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jTextFieldSalary, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCheckBoxPermenant)
                    .addComponent(jCheckBoxSelfEmployed))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel10.setText(bundle.getString("EmploymentDetails.jLabel10.text")); // NOI18N

        jLabel12.setText(bundle.getString("EmploymentDetails.jLabel12.text")); // NOI18N

        jLabel13.setText(bundle.getString("EmploymentDetails.jLabel13.text")); // NOI18N

        jLabel14.setText(bundle.getString("EmploymentDetails.jLabel14.text")); // NOI18N

        jLabel16.setText(bundle.getString("EmploymentDetails.jLabel16.text")); // NOI18N

        jLabel15.setText(bundle.getString("EmploymentDetails.jLabel15.text")); // NOI18N

        jTextFieldName.setText(bundle.getString("EmploymentDetails.jTextFieldName.text")); // NOI18N

        jTextFieldStreet.setText(bundle.getString("EmploymentDetails.jTextFieldStreet.text")); // NOI18N

        jTextFieldTown.setText(bundle.getString("EmploymentDetails.jTextFieldTown.text")); // NOI18N

        jTextFieldCountry.setText(bundle.getString("EmploymentDetails.jTextFieldCountry.text")); // NOI18N

        jTextFieldPostCode.setText(bundle.getString("EmploymentDetails.jTextFieldPostCode.text")); // NOI18N

        jButtonSubmit.setBackground(new java.awt.Color(255, 255, 255));
        jButtonSubmit.setText(bundle.getString("EmploymentDetails.jButtonSubmit.text")); // NOI18N
        jButtonSubmit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSubmitActionPerformed(evt);
            }
        });

        jButtonBack.setBackground(new java.awt.Color(255, 255, 255));
        jButtonBack.setText(bundle.getString("EmploymentDetails.jButtonBack.text")); // NOI18N
        jButtonBack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBackActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel12)
                                .addComponent(jLabel13)
                                .addComponent(jLabel14)
                                .addComponent(jLabel16)
                                .addComponent(jLabel15))
                            .addComponent(jButtonSubmit))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButtonBack)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jTextFieldPostCode)
                                .addComponent(jTextFieldCountry)
                                .addComponent(jTextFieldTown)
                                .addComponent(jTextFieldStreet)
                                .addComponent(jTextFieldName, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jLabel10)
                .addGap(29, 29, 29)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jTextFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(jTextFieldStreet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(jTextFieldTown, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(jTextFieldCountry, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(jTextFieldPostCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(31, 31, 31)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonBack)
                    .addComponent(jButtonSubmit))
                .addContainerGap(55, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(31, 31, 31)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButtonBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBackActionPerformed
    dispose();
}//GEN-LAST:event_jButtonBackActionPerformed

private void jButtonSubmitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSubmitActionPerformed
    Address address;
    try {
        address = new Address(
                employment.getEmployerAddressObject().getAddressID(),
                jTextFieldName.getText(), jTextFieldStreet.getText(),
                jTextFieldTown.getText(), jTextFieldCountry.getText(),
                jTextFieldPostCode.getText());
    } catch(IllegalArgumentException e) {
        JOptionPane.showMessageDialog(null, "Exception: " + e.toString(),
                "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    
    String[] startDate = jTextFieldStarted.getText().split("/");
    if(startDate.length != 3) {
        JOptionPane.showMessageDialog(null, "The employment details could " +
                "not be added to the database as the start date is not in " +
                "the format DD/MM/YYYY.", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }

    GregorianCalendar startDateObject;
    try {
        startDateObject = new GregorianCalendar(Integer.parseInt(startDate[2]),
                Integer.parseInt(startDate[1]), Integer.parseInt(startDate[0]));
    } catch(NumberFormatException e) {
        JOptionPane.showMessageDialog(null, "The employment details could " +
                "not be added to the database as the start date is not in " +
                "the format DD/MM/YYYY.", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    
    GregorianCalendar endDateObject = null;
    if(jTextFieldEnded.getText().length() != 0) {
        String[] endDate = jTextFieldStarted.getText().split("/");
        if(startDate.length != 3) {
            JOptionPane.showMessageDialog(null, "The employment details could " +
                "not be added to the database as the end date is not in the " +
                "format DD/MM/YYYY.", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }

        try {
            startDateObject = new GregorianCalendar(Integer.parseInt(endDate[2]),
                Integer.parseInt(endDate[1]), Integer.parseInt(endDate[0]));
        } catch(NumberFormatException e) {
            JOptionPane.showMessageDialog(null, "The employment details could " +
                "not be added to the database as the end date is not in the " +
                "format DD/MM/YYYY.", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
    }
    
    float hoursPerWeek;
    float annualSalary;
    
    try {
        hoursPerWeek = Float.parseFloat(jTextFieldHours.getText().trim());
    } catch(NumberFormatException e) {
        JOptionPane.showMessageDialog(null, "The hours per week field must " +
                "be entered in the format hours.percentage of hour, for " +
                "example, 35 and a half hours would be 35.5", "Error",
                JOptionPane.ERROR_MESSAGE);
        return;
    }
    
    try {
        annualSalary = Float.parseFloat(jTextFieldSalary.getText().trim());
    } catch(NumberFormatException e) {
        JOptionPane.showMessageDialog(null, "The annual salary must be in a " +
                "currency format.", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    
    try {
        if(core.modifyEmploymentDetails(new Employment(employment.getEmploymentID(),
                jTextFieldName.getText(), address, jTextFieldPhone.getText(),
                jTextFieldFax.getText(), startDateObject, endDateObject,
                hoursPerWeek, annualSalary, jCheckBoxPermenant.isSelected(),
                jCheckBoxSelfEmployed.isSelected()), customer.getID())) {
            JOptionPane.showMessageDialog(null, "The employment details " +
                    "were successfully added to the database.", "Error",
                    JOptionPane.PLAIN_MESSAGE);
            dispose();
            return;
        } else {
            JOptionPane.showMessageDialog(null, "The employment details " +
                    "failed to be added to the database.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return;
        }
    } catch(IllegalArgumentException e) {
        JOptionPane.showMessageDialog(null, "Exception: " + e.toString(),
                "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
}//GEN-LAST:event_jButtonSubmitActionPerformed
  
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonBack;
    private javax.swing.JButton jButtonSubmit;
    private javax.swing.JCheckBox jCheckBoxPermenant;
    private javax.swing.JCheckBox jCheckBoxSelfEmployed;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabelID;
    private javax.swing.JLabel jLabelIcon;
    private javax.swing.JLabel jLabelName;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTextField jTextFieldCountry;
    private javax.swing.JTextField jTextFieldEmployerName;
    private javax.swing.JTextField jTextFieldEnded;
    private javax.swing.JTextField jTextFieldFax;
    private javax.swing.JTextField jTextFieldHours;
    private javax.swing.JTextField jTextFieldName;
    private javax.swing.JTextField jTextFieldPhone;
    private javax.swing.JTextField jTextFieldPostCode;
    private javax.swing.JTextField jTextFieldSalary;
    private javax.swing.JTextField jTextFieldStarted;
    private javax.swing.JTextField jTextFieldStreet;
    private javax.swing.JTextField jTextFieldTown;
    // End of variables declaration//GEN-END:variables

}
